#include "StdAfx.h"
#include "Billboard.h"
#include "BillboardSet.h"

VAMPIRE_NAMESPACE_BEGIN

Billboard::Billboard(void)
: mOwnDimensions(false), mUseTexcoordRect(false), mTexcoordIndex(0), mPosition(Vector3::ZERO),
  mDirection(Vector3::ZERO), mpParentSet(NULL), mColor(ColorValue::WHITE), mRotation(0.0f)
{
}

Billboard::Billboard( const Vector3& position, BillboardSet* owner, const ColorValue& color /*= ColorValue::WHITE*/ )
: mOwnDimensions(false), mUseTexcoordRect(false), mTexcoordIndex(0), mPosition(position), 
  mDirection(Vector3::ZERO), mpParentSet(owner), mColor(color), mRotation(0.0f)
{
}

const Radian& Billboard::getRotation() const
{
	return mRotation;
}

void Billboard::setRotation( const Radian& rotation )
{
	mRotation = rotation;
	if (mRotation != Radian(0.0f))
	{

	}
}

void Billboard::setPosition( const Vector3& position )
{
	mPosition = position;
}

void Billboard::setPosition( Real x, Real y, Real z )
{
	mPosition.mData.x = x;
	mPosition.mData.y = y;
	mPosition.mData.z = z;
}

const Vector3& Billboard::getPosition() const
{
	return mPosition;
}

void Billboard::setDimensions( Real width, Real height )
{
	mOwnDimensions = true;
	mWidth         = width;
	mHeight        = height;
	//////////////////////////////////////////////////////////////////////////
}

void Billboard::resetDimensions()
{
	mOwnDimensions = false;
}

void Billboard::setColor( const ColorValue& color )
{
	mColor = color;
}

const ColorValue& Billboard::getColor() const
{
	return mColor;
}

bool Billboard::hasOwnDimensions() const
{
	return mOwnDimensions;
}

Vampire::Real Billboard::getOwnWidth() const
{
	return mWidth;
}

Vampire::Real Billboard::getOwnHeight() const
{
	return mHeight;
}

void Billboard::_notifyOwner( BillboardSet* owner )
{
	mpParentSet = owner;
}

bool Billboard::isUseTexcoordRect() const
{
	return mUseTexcoordRect;
}

void Billboard::setTexcoordIndex( uint16 texcoordIndex )
{
	mTexcoordIndex   = texcoordIndex;
	mUseTexcoordRect = false;
}

Vampire::uint16 Billboard::getTexcoordIndex() const
{
	return mTexcoordIndex;
}

void Billboard::setTexcoordRect( const FloatRect& texcoordRect )
{
	mTexcoordRect = texcoordRect;
	mUseTexcoordRect = true;
}

void Billboard::setTexcoordRect( Real u0, Real v0, Real u1, Real v1 )
{
	mTexcoordRect.left    = u0;
	mTexcoordRect.top     = v0;
	mTexcoordRect.right   = u1;
	mTexcoordRect.bottom  = v1;
	mUseTexcoordRect      = true;
}

const FloatRect& Billboard::getTexcoordRect() const
{
	return mTexcoordRect;
}

VAMPIRE_NAMESPACE_END